cap log close

*Set working directory
cd "C:\Users\fornaro\Desktop\PhD new\Working papers\abortion\Manuscript\PSRM submission\Replication"

log using "Replication_PSRM-2024-0085.R1.smcl", replace

****************   DATA CLEANING ****************

use "Main_dataset_PSRM-2024-0085.R1.dta", clear

drop if status == "Spam"

drop if consentinformation == "No, I do not consent and will exit the survey."

drop if attention != 11

foreach x in abo_statusquo1_1 abo_statusquo1_2 abo_statusquo1_3 abo_statusquo1_4 abo_statusquo2_1 abo_statusquo2_2 abo_statusquo2_3 abo_attitudes1_1 abo_attitudes1_2 abo_attitudes1_3 abo_attitudes1_4 abo_attitudes2_1 abo_attitudes2_2 abo_attitudes2_3 abo_morality abo_trustscotus abo_repscotus abo_trustleg abo_repleg abo_treat {
	encode `x', generate(`x'cat)
}

encode gender, generate(gender_cat)
tab gender_cat, missing
gen gender_new = .
replace gender_new = 1 if gender == "Female"
replace gender_new = 0 if gender == "Male"
tab gender_new abortion_treat, missing

encode hispanicorigin, generate(hispanicorigin_cat)
tab hispanicorigin_cat, missing
gen hispanic_new = .
replace hispanic_new = 1 if hispanicorigin == "Yes"
replace hispanic_new = 0 if hispanicorigin == "No"
tab hispanic_new abortion_treat, missing

encode ethnicity, generate(ethnicity_cat)
tab ethnicity_cat, missing
gen ethnicity_new = .
replace ethnicity_new = 1 if ethnicity == "Black or African American"
replace ethnicity_new = 0 if ethnicity == "White"
replace ethnicity_new = 2 if (ethnicity != "White" & ethnicity != "Black or African American")
tab ethnicity_new abortion_treat, missing

encode urban_rural, generate(urban_ruralcat)
tab urban_ruralcat, missing
tab urban_ruralcat abortion_treat, missing

encode ideology, generate(ideologycat)
tab ideologycat, missing

encode biblical_literalism, generate(biblical_literalismcat)
tab biblical_literalismcat, missing
tab biblical_literalismcat abortion_treat, missing

gen biblical_literalismnew = .
replace biblical_literalismnew = 1 if biblical_literalism == "The Bible represents the literal word of God"
replace biblical_literalismnew = 0 if biblical_literalism != "The Bible represents the literal word of God"
tab biblical_literalismnew, missing

encode partisan, generate(partisancat)
tab partisancat, missing
tab partisancat abortion_treat, missing

encode abo_identity, generate(abo_identitycat)
tab abo_identitycat, missing
tab abo_identitycat abortion_treat, missing

gen prolife = .
replace prolife = 1 if abo_identity == "Pro-life"
replace prolife = 0 if abo_identity != "Pro-life"
tab prolife, missing

encode education, generate(educationcat)
tab educationcat, missing
gen education_new = .
replace education_new = 0 if education == "Less than high school - No diploma"
replace education_new = 1 if education == "High school graduate - High school diploma or equivalent (For example: GED)" 
replace education_new = 2 if education == "Some college, no degree" | education == "Associate degree in college - Academic program"| education == "Associate degree in college - Occupational/vocational program"
replace education_new = 3 if education == "Bachelor's degree (For example: BA, BS)"
replace education_new = 4 if education == "Master's degree (For example:  MA, MS, MEd, MSW, MBA)" | education == "Doctorate degree (For example: PhD, EdD)" | education == "Professional school Degree (For example: MD,DDS,DVM,LLB,JD)"
tab education_new, missing
tab education_new abortion_treat, missing

encode religion, generate(religioncat)
tab religioncat, missing
gen religion_new = .
replace religion_new = 0 if religion == "Catholic Christian"
replace religion_new = 1 if religion == "Evangelical Protestant Christian"
replace religion_new = 2 if religion == "Mainline Protestant Christian"
replace religion_new = 3 if religion == "Agnostic" | religion == "Atheist"
replace religion_new = 4 if religion == "Buddhist" | religion == "Hindu" | religion == "Jewish" | religion == "Muslim" | religion == "Other"
tab religion_new, missing
tab religion_new abortion_treat, missing

gen parent = .
replace parent = 1 if children == "Yes"
replace parent = 0 if children == "No"
tab parent, missing

local vars abo_attitudes1_1 abo_attitudes1_2 abo_attitudes1_3 abo_attitudes1_4 abo_attitudes2_1 abo_attitudes2_2 abo_attitudes2_3 abo_statusquo1_1 abo_statusquo1_2 abo_statusquo1_3 abo_statusquo1_4 abo_statusquo2_1 abo_statusquo2_2 abo_statusquo2_3
foreach var in `vars' {
    gen `var'num = .
    replace `var'num = -3 if `var' == "Strongly oppose"
    replace `var'num = -2 if `var' == "Oppose"
    replace `var'num = -1 if `var' == "Somewhat oppose"
    replace `var'num =  0 if `var' == "Neither oppose nor support"
    replace `var'num =  1 if `var' == "Somewhat support"
    replace `var'num =  2 if `var' == "Support"
    replace `var'num =  3 if `var' == "Strongly support"
    tab `var'num, missing
}


local vars abo_trustscotus abo_trustleg
foreach var in `vars' {
    gen `var'num = .
    replace `var'num = -3 if `var' == "Strongly mistrust"
    replace `var'num = -2 if `var' == "Mistrust"
    replace `var'num = -1 if `var' == "Somewhat mistrust"
    replace `var'num =  0 if `var' == "Neither mistrust nor trust"
    replace `var'num =  1 if `var' == "Somewhat trust"
    replace `var'num =  2 if `var' == "Trust"
    replace `var'num =  3 if `var' == "Strongly trust"
    tab `var'num, missing
}


local vars abo_repscotus abo_repleg
foreach var in `vars' {
    gen `var'num = .
    replace `var'num = -2 if `var' == "Do not represent public opinion at all"
    replace `var'num = -1 if `var' == "Hardly represent public opinion"
    replace `var'num =  0 if `var' == "Now and then represent public opinion"
    replace `var'num =  1 if `var' == "Somewhat represent public opinion"
    replace `var'num =  2 if `var' == "Very much represent public opinion"
    tab `var'num, missing
}

gen abo_treatnum = .
replace abo_treatnum = 0 if abo_treat == "None of it"
replace abo_treatnum = 1 if abo_treat == "Very little of it"
replace abo_treatnum = 2 if abo_treat == "Some of it"
replace abo_treatnum = 3 if abo_treat == "Most of it"
replace abo_treatnum = 4 if abo_treat == "All of it"
tab abo_treatnum, missing

local attitudes abo_attitudes1_1num abo_attitudes1_2num abo_attitudes1_3num abo_attitudes1_4num abo_attitudes2_1num abo_attitudes2_2num abo_attitudes2_3num
local statusquo abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num
local diffs absdiff_any absdiff_defct absdiff_health absdiff_married absdiff_poor absdiff_rape absdiff_notmarried
forval i = 1/7 {
    gen `: word `i' of `diffs'' = abs(`: word `i' of `attitudes'' - `: word `i' of `statusquo'')
}

local attitudes abo_attitudes1_1num abo_attitudes1_2num abo_attitudes1_3num abo_attitudes1_4num abo_attitudes2_1num abo_attitudes2_2num abo_attitudes2_3num
local means mean_trueany mean_truedfct mean_truehealth mean_truenomorechild mean_truepoor mean_truerape mean_truenotmarried
forval i = 1/7 {
    egen `: word `i' of `means'' = mean(`: word `i' of `attitudes'')
}

local means mean_trueany mean_truedfct mean_truehealth mean_truenomorechild mean_truepoor mean_truerape mean_truenotmarried
local statusquo abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num
local diffs absdiffnew_any absdiffnew_defct absdiffnew_health absdiffnew_married absdiffnew_poor absdiffnew_rape absdiffnew_notmarried
forval i = 1/7 {
    gen `: word `i' of `diffs'' = abs(`: word `i' of `means'' - `: word `i' of `statusquo'')
}

tabulate state, generate(state_dummy)

label variable gender_new "Female"
label variable parent "Parent"
label variable hispanic_new "Hispanic"
label variable age1 "Age"
label variable biblical_literalismnew "Bible is the word of God"
label variable abo_trustscotusnum "Trust in SCOTUS"
label variable abo_repscotusnum "SCOTUS representativeness"
label variable abo_trustlegnum "Trust in state legislatures"
label variable abo_replegnum "State legislatures representativeness"
label variable abo_treatnum "Knowledge about Dobbs decision"

label define ethnicity_new 0 "White" 1 "Black or African American" 2 "Other"
label values ethnicity_new ethnicity_new

label define education_new 0 "Less than high school" 1 "High school" 2 "Some college" 3 "Bachelor's degree" 4 "Master's degree, PhD"
label values education_new education_new

label define religion_new 0 "Catholic" 1 "Evangelical" 2 "Mainline protestant" 3 "Agnostic, atheist" 4 "Other"
label values religion_new religion_new

label define aboidentilabel 1 "Either" 2 "Neither" 3 "Pro-choice" 4 "Pro-life"
label values abo_identitycat aboidentilabel

*Dataset saved under the name "Dataset_after_data_cleaning_PSRM-2024-0085.R1.dta"

****************   FIGURE 1   ****************
use "Dataset_after_data_cleaning_PSRM-2024-0085.R1.dta", clear

local vars abo_attitudes1_1num abo_attitudes1_2num abo_attitudes1_3num abo_attitudes1_4num abo_attitudes2_1num abo_attitudes2_2num abo_attitudes2_3num abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num

collapse (mean) `vars' seabo_attitudes1_1num = abo_attitudes1_1num seabo_attitudes1_2num = abo_attitudes1_2num seabo_attitudes1_3num = abo_attitudes1_3num seabo_attitudes1_4num = abo_attitudes1_4num seabo_attitudes2_1num = abo_attitudes2_1num seabo_attitudes2_2num = abo_attitudes2_2num seabo_attitudes2_3num = abo_attitudes2_3num seabo_statusquo1_1num = abo_statusquo1_1num seabo_statusquo1_2num = abo_statusquo1_2num seabo_statusquo1_3num = abo_statusquo1_3num seabo_statusquo1_4num = abo_statusquo1_4num seabo_statusquo2_1num = abo_statusquo2_1num seabo_statusquo2_2num = abo_statusquo2_2num seabo_statusquo2_3num = abo_statusquo2_3num
* The resulting collapsed dataset is copied externally to an excel file to create a ad-hoc dataset to produce the figure (Dataset_Figure1_PSRM-2024-0085.R1.dta)

use "Dataset_after_data_cleaning_PSRM-2024-0085.R1.dta", clear

local vars abo_attitudes1_1num abo_attitudes1_2num abo_attitudes1_3num abo_attitudes1_4num abo_attitudes2_1num abo_attitudes2_2num abo_attitudes2_3num abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num

collapse (semean) `vars' seabo_attitudes1_1num = abo_attitudes1_1num seabo_attitudes1_2num = abo_attitudes1_2num seabo_attitudes1_3num = abo_attitudes1_3num seabo_attitudes1_4num = abo_attitudes1_4num seabo_attitudes2_1num = abo_attitudes2_1num seabo_attitudes2_2num = abo_attitudes2_2num seabo_attitudes2_3num = abo_attitudes2_3num seabo_statusquo1_1num = abo_statusquo1_1num seabo_statusquo1_2num = abo_statusquo1_2num seabo_statusquo1_3num = abo_statusquo1_3num seabo_statusquo1_4num = abo_statusquo1_4num seabo_statusquo2_1num = abo_statusquo2_1num seabo_statusquo2_2num = abo_statusquo2_2num seabo_statusquo2_3num = abo_statusquo2_3num
* The resulting collapsed dataset is copied externally to an excel spreadsheet to create a ad-hoc dataset to produce the figure (Dataset_Figure1_PSRM-2024-0085.R1.dta)

use "Dataset_Figure1_PSRM-2024-0085.R1.dta", clear

label define cause_label 1 "Any" 2 "No more children" 3 "Cannot afford" 4 "Not married" 5 "Birth defect" 6 "Woman's health" 7 "Rape", replace
label values cause cause_label
label define type_label 1 "Actual" 2 "Perceived", replace
label values type type_label

gen lb = mean_support - semean_support
gen ub = mean_support + semean_support
	
generate causetype = type    if cause == 1
replace  causetype = type+5  if cause == 2
replace  causetype = type+10  if cause == 3
replace  causetype = type+15  if cause == 4
replace  causetype = type+20  if cause == 5
replace  causetype = type+25  if cause == 6
replace  causetype = type+30  if cause == 7

sort causetype
list causetype type cause, sepby(cause)

set scheme s1mono

twoway (bar mean_support causetype if type==1) (bar mean_support causetype if type==2) (rcap lb ub causetype), legend( order(1 "Actual" 2 "Perceived") )
*The additional layout modifications to achieve the final version of the figure were implemented directly from STATA graph editor

****************   FIGURE 2   ****************
use "Dataset_after_data_cleaning_PSRM-2024-0085.R1.dta", clear

set scheme s1mono

quietly eststo Any: reg absdiffnew_any gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
quietly eststo Nomorechildren: reg absdiffnew_married gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
quietly eststo Cantafford: reg absdiffnew_poor gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
quietly eststo Notmarried: reg absdiffnew_notmarried gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
coefplot Any || Nomorechildren || Cantafford || Notmarried, keep(*.abo_identitycat *.ideologycat) xline(0) ///
headings(1.abo_identitycat = "{bf: Abortion identity label (Ref: Pro-choice)}" ///
2.ideologycat = "{bf: Ideology (Ref: Moderate)}", labcolor(black) labsize(medium small))
*The additional layout modifications to achieve the final version of the figure were implemented directly from STATA graph editor

quietly eststo Birthdefect: reg absdiffnew_defct gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
quietly eststo 	Womanshealth: reg absdiffnew_health gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
quietly eststo Rape: reg absdiffnew_rape gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
coefplot Birthdefect || Womanshealth || Rape, keep(*.abo_identitycat *.ideologycat) xline(0) ///
headings(1.abo_identitycat = "{bf: Abortion identity label (Ref: Pro-choice)}" ///
2.ideologycat = "{bf: Ideology (Ref: Moderate)}", labcolor(black) labsize(medium small))
*The additional layout modifications to achieve the final version of the figure were implemented directly from STATA graph editor

****************   FIGURE 3   ****************

graph bar abo_attitudes1_1num abo_statusquo1_1num, over(abo_identitycat) yline(0.1467) legend(off)
graph bar abo_attitudes1_2num abo_statusquo1_2num, over(abo_identitycat) yline(1.1038) legend(off)
graph bar abo_attitudes1_3num abo_statusquo1_3num, over(abo_identitycat) yline(1.5564) legend(off)
graph bar abo_attitudes1_4num abo_statusquo1_4num, over(abo_identitycat) yline(0.0710) legend(off)
graph bar abo_attitudes2_1num abo_statusquo2_1num, over(abo_identitycat) yline(0.2402) legend(off)
graph bar abo_attitudes2_2num abo_statusquo2_2num, over(abo_identitycat) yline(1.5121) legend(off)
graph bar abo_attitudes2_3num abo_statusquo2_3num, over(abo_identitycat) yline(0.1113) legend(off)
*The additional layout modifications to achieve the final version of the figure were implemented directly from STATA graph editor. These subfigures were combined to achieve the final version.

****************   SUPPLEMENTARY MATERIALS   ****************

****************   TABLE A.1   ****************

gen agegroup1=.
replace agegroup1 = 1 if age1 >= 18 & age1 <=34
replace agegroup1 = 0 if age1 < 18 | age1 > 34
tab agegroup1, missing

gen agegroup2=.
replace agegroup2 = 1 if age1 >= 35 & age1 <= 54
replace agegroup2 = 0 if age1 < 35 | age1 > 54
tab agegroup2, missing

gen agegroup3=.
replace agegroup3 = 1 if age1 >= 55
replace agegroup3 = 0 if age1 < 55
tab agegroup3, missing

gen agegroup = .
replace agegroup = 1 if agegroup1 == 1
replace agegroup = 2 if agegroup2 == 1
replace agegroup = 3 if agegroup3 == 1
tab agegroup, missing

foreach x in gender hispanic_new ethnicity_new agegroup education_new partisancat religion_new abo_identitycat state {
	tab `x', missing
}

****************   TABLE A.2   ****************

local attitudes abo_attitudes1_1num abo_attitudes1_4num abo_attitudes2_1num abo_attitudes2_3num abo_attitudes1_2num abo_attitudes1_3num abo_attitudes2_2num
local statusquo abo_statusquo1_1num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_3num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo2_2num
forval i = 1/7 {
    ttest `: word `i' of `attitudes'' == `: word `i' of `statusquo''
}

****************   TABLE A.3   ****************

local attitudes abo_attitudes1_1num abo_attitudes1_4num abo_attitudes2_1num abo_attitudes2_3num abo_attitudes1_2num abo_attitudes1_3num abo_attitudes2_2num
local statusquo abo_statusquo1_1num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_3num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo2_2num
forval i = 1/7 {
    signrank `: word `i' of `attitudes'' = `: word `i' of `statusquo''
}

****************   FIGURE A.1   ****************

quietly eststo Any: reg abo_statusquo1_1num gender_new parent hispanic_new age1 biblical_literalismnew abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum ib0.ethnicity_new ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new state_dummy*
quietly eststo Nomorechildren: reg abo_statusquo1_4num gender_new parent hispanic_new age1 biblical_literalismnew abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum ib0.ethnicity_new ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new state_dummy*
coefplot Any || Nomorechildren, drop(_cons state_dummy*) xline(0) ///
headings(1.ethnicity_new = "{bf: Race (Ref: Caucasian)}" /// 
1.urban_ruralcat = "{bf: Rurality (Ref: Urban)}" ///
1.partisancat = "{bf: Partisanship (Ref: Republican)}" ///
2.ideologycat = "{bf: Ideology (Ref: Moderate)}" ///
1.abo_identitycat = "{bf: Abortion identity label (Ref: Pro-choice)}" ///
1.education_new = "{bf: Education (Ref: Less than high school)}" ///
1.religion_new = "{bf: Religion (Ref: Catholic)}", labcolor(black) labsize(vsmall))

quietly eststo Cantafford: reg abo_statusquo2_1num gender_new parent hispanic_new age1 biblical_literalismnew abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum ib0.ethnicity_new ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new state_dummy*
quietly eststo Notmarried: reg abo_statusquo2_3num gender_new parent hispanic_new age1 biblical_literalismnew abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum ib0.ethnicity_new ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new state_dummy*
coefplot Cantafford || Notmarried, drop(_cons state_dummy*) xline(0) ///
headings(1.ethnicity_new = "{bf: Race (Ref: Caucasian)}" /// 
1.urban_ruralcat = "{bf: Rurality (Ref: Urban)}" ///
1.partisancat = "{bf: Partisanship (Ref: Republican)}" ///
2.ideologycat = "{bf: Ideology (Ref: Moderate)}" ///
1.abo_identitycat = "{bf: Abortion identity label (Ref: Pro-choice)}" ///
1.education_new = "{bf: Education (Ref: Less than high school)}" ///
1.religion_new = "{bf: Religion (Ref: Catholic)}", labcolor(black) labsize(vsmall))

quietly eststo Birthdefect: reg abo_statusquo1_2num gender_new parent hispanic_new age1 biblical_literalismnew abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum ib0.ethnicity_new ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new state_dummy*
quietly eststo 	Womanshealth: reg abo_statusquo1_3num gender_new parent hispanic_new age1 biblical_literalismnew abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum ib0.ethnicity_new ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new state_dummy*
coefplot Birthdefect || Womanshealth, drop(_cons state_dummy*) xline(0) ///
headings(1.ethnicity_new = "{bf: Race (Ref: Caucasian)}" /// 
1.urban_ruralcat = "{bf: Rurality (Ref: Urban)}" ///
1.partisancat = "{bf: Partisanship (Ref: Republican)}" ///
2.ideologycat = "{bf: Ideology (Ref: Moderate)}" ///
1.abo_identitycat = "{bf: Abortion identity label (Ref: Pro-choice)}" ///
1.education_new = "{bf: Education (Ref: Less than high school)}" ///
1.religion_new = "{bf: Religion (Ref: Catholic)}", labcolor(black) labsize(vsmall))

pca abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num
rotate
predict pca_statusquooverall
alpha abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num

quietly eststo Rape: reg abo_statusquo2_2num gender_new parent hispanic_new age1 biblical_literalismnew abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum ib0.ethnicity_new ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new state_dummy*
quietly eststo 	PCA: reg pca_statusquooverall gender_new parent hispanic_new age1 biblical_literalismnew abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum ib0.ethnicity_new ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new state_dummy*
coefplot Rape || PCA, drop(_cons state_dummy*) xline(0) ///
headings(1.ethnicity_new = "{bf: Race (Ref: Caucasian)}" /// 
1.urban_ruralcat = "{bf: Rurality (Ref: Urban)}" ///
1.partisancat = "{bf: Partisanship (Ref: Republican)}" ///
2.ideologycat = "{bf: Ideology (Ref: Moderate)}" ///
1.abo_identitycat = "{bf: Abortion identity label (Ref: Pro-choice)}" ///
1.education_new = "{bf: Education (Ref: Less than high school)}" ///
1.religion_new = "{bf: Religion (Ref: Catholic)}", labcolor(black) labsize(vsmall))

****************   TABLE A.4   ****************

est clear

local depvars abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num pca_statusquooverall
foreach depvar of local depvars {
    quietly reg `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(2) varwidth(2) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.5   ****************
est clear

local depvars abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num
foreach depvar of local depvars {
    quietly ologit `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"

****************   TABLE A.6   ****************

est clear

encode state, generate(statenew)

ebalance i.gender_new i.agegroup i.ethnicity_new i.education_new i.statenew, manualtargets(0.504 0.3352 0.3964 0.12 0.27 0.28 0.25 0.23 0.15 0.0022 0.0221 0.0091 0.1171 0.0175 0.0109 0.0031 0.0020 0.0667 0.0327 0.0043 0.0058 0.0378 0.0205 0.0096 0.0088 0.0135 0.0138 0.0042 0.0185 0.0209 0.0301 0.0172 0.0088 0.0185 0.0034 0.0059 0.0095 0.0042 0.0278 0.0063 0.0590 0.0321 0.0023 0.0353 0.0121 0.0127 0.0389 0.0033 0.0159 0.0027 0.0212 0.0901 0.0101 0.0019 0.0261 0.0234 0.0053 0.0177 0.0017)

local depvars abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num
foreach depvar of local depvars {
    quietly reg `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy* [w = _webal]
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"

****************   TABLE A.7   ****************

est clear

local depvars abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num
foreach depvar of local depvars {
    quietly reg `depvar' abortion_treat gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.8   ****************

est clear 

local depvars abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num
foreach depvar of local depvars {
    quietly reg `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"

****************   TABLE A.9   ****************

est clear 

local depvars absdiffnew_any absdiffnew_defct absdiffnew_health absdiffnew_married absdiffnew_poor absdiffnew_rape absdiffnew_notmarried 
foreach depvar of local depvars {
    quietly reg `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.10   ****************

est clear 

local depvars absdiffnew_any absdiffnew_defct absdiffnew_health absdiffnew_married absdiffnew_poor absdiffnew_rape absdiffnew_notmarried 
foreach depvar of local depvars {
    quietly ologit `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.11   ****************

est clear 

local depvars absdiffnew_any absdiffnew_defct absdiffnew_health absdiffnew_married absdiffnew_poor absdiffnew_rape absdiffnew_notmarried 
foreach depvar of local depvars {
    quietly reg `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy* [w = _webal]
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.12   ****************

est clear 

local depvars absdiffnew_any absdiffnew_defct absdiffnew_health absdiffnew_married absdiffnew_poor absdiffnew_rape absdiffnew_notmarried 
foreach depvar of local depvars {
    quietly reg `depvar' abortion_treat gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"

****************   TABLE A.13   ****************

tabstat abo_attitudes1_1num abo_attitudes1_2num abo_attitudes1_3num abo_attitudes1_4num abo_attitudes2_1num abo_attitudes2_2num abo_attitudes2_3num, by(abo_identitycat)

tabstat abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num, by(abo_identitycat)

****************   TABLE A.14   ****************

est clear 

local depvars absdiff_any absdiff_defct absdiff_health absdiff_married absdiff_poor absdiff_rape absdiff_notmarried 
foreach depvar of local depvars {
    quietly reg `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.15   ****************

est clear

local depvars absdiff_any absdiff_defct absdiff_health absdiff_married absdiff_poor absdiff_rape absdiff_notmarried 
foreach depvar of local depvars {
    quietly ologit `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.16   ****************

est clear

local depvars absdiff_any absdiff_defct absdiff_health absdiff_married absdiff_poor absdiff_rape absdiff_notmarried 
foreach depvar of local depvars {
    quietly reg `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy* [w = _webal]
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.17   ****************

est clear

local depvars absdiff_any absdiff_defct absdiff_health absdiff_married absdiff_poor absdiff_rape absdiff_notmarried 
foreach depvar of local depvars {
    quietly reg `depvar' abortion_treat gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"

****************   TABLE A.18   ****************

local pairs "1_1num 1_2num 1_3num 1_4num 2_1num 2_2num 2_3num"
local suffixes "any1 defct1 health1 married1 poor1 rape1 notmarried1"
forval i = 1/7 {
    local pair : word `i' of `pairs'
    local suffix : word `i' of `suffixes'

    gen publiclesssup_`suffix' = .
    replace publiclesssup_`suffix' = 1 if abo_statusquo`pair' < abo_attitudes`pair'
    replace publiclesssup_`suffix' = 0 if abo_statusquo`pair' >= abo_attitudes`pair'
    replace publiclesssup_`suffix' = . if abo_statusquo`pair' == . | abo_attitudes`pair' == .
    
    tab publiclesssup_`suffix', missing
}

est clear

local depvars publiclesssup_any1 publiclesssup_defct1 publiclesssup_health1 publiclesssup_married1 publiclesssup_poor1 publiclesssup_rape1 publiclesssup_notmarried1
foreach depvar of local depvars {
    quietly logit `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new biblical_literalismnew ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*, or
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    eform se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.19   ****************

est clear

local depvars publiclesssup_any1 publiclesssup_defct1 publiclesssup_health1 publiclesssup_married1 publiclesssup_poor1 publiclesssup_rape1 publiclesssup_notmarried1
foreach depvar of local depvars {
    quietly logit `depvar' abortion_treat gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new biblical_literalismnew ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*, or
	est store m_`depvar'
}

esttab m_* using "regression_table.txt", replace label ///
    eform se star(* 0.1 ** 0.05 *** 0.001 **** 0.0001) ///
    b(%9.3f) se(%9.3f) ///
	modelwidth(4) varwidth(4) ///
    stats(r2 N, labels("R-squared" "Observations"))

type "regression_table.txt"


****************   TABLE A.20   ****************

tab abo_identitycat partisancat, chi2 nolabel row

****************   TABLE A.21   ****************

tab abo_identitycat ideologycat, chi2 nolabel row

****************   TABLE A.22   ****************

foreach x in abo_attitudes1_1num abo_attitudes1_2num abo_attitudes1_3num abo_attitudes1_4num abo_attitudes2_1num abo_attitudes2_2num abo_attitudes2_3num {
	sum `x'
	scalar mean_`x' = r(mean)
}

foreach x in abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num  {
	sum `x' if abo_identitycat == 4
	scalar meanpl_`x' = r(mean)
}

foreach x in abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num  {
	sum `x' if abo_identitycat == 3
	scalar meanpc_`x' = r(mean)
}

local i = 1 
foreach x in mean_abo_attitudes1_1num mean_abo_attitudes1_2num mean_abo_attitudes1_3num mean_abo_attitudes1_4num mean_abo_attitudes2_1num mean_abo_attitudes2_2num mean_abo_attitudes2_3num {
    local y: word `i' of meanpl_abo_statusquo1_1num meanpl_abo_statusquo1_2num meanpl_abo_statusquo1_3num meanpl_abo_statusquo1_4num meanpl_abo_statusquo2_1num meanpl_abo_statusquo2_2num meanpl_abo_statusquo2_3num
    display "x = `x', y = `y', abs(x-y) = " abs(`x' - `y')
    local i = `i' + 1
}

local i = 1 
foreach x in mean_abo_attitudes1_1num mean_abo_attitudes1_2num mean_abo_attitudes1_3num mean_abo_attitudes1_4num mean_abo_attitudes2_1num mean_abo_attitudes2_2num mean_abo_attitudes2_3num {
    local y: word `i' of meanpc_abo_statusquo1_1num meanpc_abo_statusquo1_2num meanpc_abo_statusquo1_3num meanpc_abo_statusquo1_4num meanpc_abo_statusquo2_1num meanpc_abo_statusquo2_2num meanpc_abo_statusquo2_3num
    display "x = `x', y = `y', abs(x-y) = " abs(`x' - `y')
    local i = `i' + 1
}

****************   TABLE A.23   ****************

local depvars abo_statusquo1_1num abo_statusquo1_2num abo_statusquo1_3num abo_statusquo1_4num abo_statusquo2_1num abo_statusquo2_2num abo_statusquo2_3num 
foreach depvar of local depvars {
    reg `depvar' gender_new parent hispanic_new ib0.ethnicity_new age1 ib3.urban_ruralcat biblical_literalismnew ib3.partisancat ib1.ideologycat ib3.abo_identitycat ib0.education_new ib0.religion_new abo_trustscotusnum abo_repscotusnum abo_trustlegnum abo_replegnum abo_treatnum state_dummy*
	return li
	mat li r(table)
}
*Manually retrieve the p-values on 4.abo_identitycat (pro-life) and divide them by 7 in a 


log close

translate "Replication_PSRM-2024-0085.R1.smcl" "Replication_PSRM-2024-0085.R1.pdf", replace

